<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class Subject extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'order' => 'bail|required|numeric',
            'subject' => 'max:500',
            'sort' => 'bail|required|numeric|in:1,2',
            'answer_1' => 'bail|required|max:190',
            'answer_2' => 'bail|required|max:190',
            'result_1' => 'bail|required|alpha|in:W,N,G,Z,S,Q,P,R,A,B,C,D,E,F,G,H,I',
            'result_2' => 'bail|required|alpha|in:W,N,G,Z,S,Q,P,R,A,B,C,D,E,F,G,H,I',
        ];
    }

    public function messages()
    {
        return [
            'order.required' => '请输入题目排序',
            'order.numeric' => '题目排序必须是一个数字',
            'subject.max' => '题目过长',
            'sort.required' => '请选择题目分类',
            'sort.numeric' => '题目分类错误',
            'sort.in' => '题目分类错误',
            'answer_1.required' => '请输入题目选项1',
            'answer_1.max' => '题目选项1过长',
            'answer_2.required' => '请输入题目选项2',
            'answer_2.max' => '题目选项2过长',
            'result_1.required' => '请输入题目选项1指向',
            'result_1.alpha' => '题目选项1指向错误',
            'result_1.in' => '题目选项1指向错误',
            'result_2.required' => '请输入题目选项2指向',
            'result_2.alpha' => '题目选项2指向错误',
            'result_2.in' => '题目选项2指向错误',
        ];
    }
}
